<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$item=pdo_get('jy_lvpai_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$item['upass']='';
	$item['endtime']=date('Y-m-d H:i:s',$item['endtime']);
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'edit'=>array(
								array('name'=>'realname','title'=>'联系人','type'=>'string'),
								array('name'=>'mobile','title'=>'联系电话','type'=>'string'),
								array('name'=>'uname','must'=>true,'title'=>'账户名','type'=>'string'),
								array('name'=>'upass','title'=>'账户密码','type'=>'string'),
								array('name'=>'qq','title'=>'QQ','type'=>'string'),
								array('name'=>'email','title'=>'邮箱','type'=>'string'),
								array('name'=>'sex','title'=>'性别','type'=>'radio','options'=>'sex'),
			)
	);
	$return['sex']=array(1=>'男',2=>'女');
	//$return['htmls']=$htmls;
	set_html('title','会员中心');
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	$data=array(
		'realname'=>$postdata['realname'],
		'avatar'=>$postdata['avatar'],
		'mobile'=>$postdata['mobile'],
		'uname'=>$postdata['uname'],
		'qq'=>$postdata['qq'],
		'email'=>$postdata['email'],
		'sex'=>$postdata['sex'],
		'status'=>intval($postdata['status']),
		'upass'=>base64_encode($post['upass']),
	);
	$id=intval($postdata['id']);
	if($id){
		if(!$post['upass']){
			unset($data['upass']);
		}
		pdo_update('jy_lvpai_member',$data,array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$data['uniacid']=$_SESSION['uniacid'];
		$data['createtime']=TIMESTAMP;
		pdo_insert('jy_lvpai_member',$data);
	}
	exi('操作成功！','','main');
}